#!/bin/bash
# rs.add( { host: "mongodbd4.example.net:27017", priority: 0 } )
source /etc/profile
/usr/local/mongodb/bin/mongo --port  "{{ hostvars[ansible_default_ipv4.address].mongodb_port }}"  --eval 'rs.initiate({_id : "{{ hostvars[ansible_default_ipv4.address].replSet_name }}",members : [{% for host in groups.all|sort %}{_id : {{ loop.index }}, host : "{{ host }}:{{ hostvars[ansible_default_ipv4.address].mongodb_port }}", priority: {{ hostvars[host].vars.priority }}},{% endfor %}]})'
